﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;

namespace SkyBase
{
    class GameOver: Overlay
    {
        private Game1 engine;

        public GameOver(Game1 engine)
            : base(Storage.getTexture("gameoverBG"), "GameOver", true)
        {
            this.engine = engine;
            hold = true;
        }

        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            //Because hold is true, whenever this overlay's update method is called
            //the game won't be running. This means that we can safely check for
            //keyboard input

            KeyboardState keyboardState = Keyboard.GetState();


            if (keyboardState.IsKeyDown(Keys.F4))
                engine.Exit();

            /*if (keyboardState.IsKeyDown(Keys.Space))
                start = true;

            //If the game is set to start, keep running the preRemove method until it sets readyForRemoval to true
            //We do this to get the fade out effect
            if (start)
            {
                preRemove();
            }*/
        }

        public override void Draw(SpriteBatch spriteBatch, Vector2 cameraPos)
        {
            engine.GraphicsDevice.Clear(Color.Black);
            Vector2 string1 = engine.arialBold.MeasureString("GAME OVER");
            Vector2 string2 = engine.arial.MeasureString("Press F4 to quit");
            Vector2 center = new Vector2((int)(cameraPos.X + bounds.Width / 2) + (engine.viewportSize.Width / 2) - (string1.X), (int)(cameraPos.Y + bounds.Height / 2) + (engine.viewportSize.Height / 2) - (string1.Y));
            //Vector2 center = new Vector2(engine.viewportSize.Center.X - string1.X, engine.viewportSize.Center.Y);
            spriteBatch.DrawString(engine.arialBold, "GAME OVER", center, Color.Red);

            spriteBatch.DrawString(engine.arialBold, "Press F4 to quit", new Vector2(center.X, center.Y + 25), Color.Red);
            base.Draw(spriteBatch, cameraPos);
        }
    }
}
